package com.micklebes.converter;

import com.google.appengine.api.datastore.KeyFactory;
import com.micklebes.entity.Storage;
import com.micklebes.entity.StorageBO;

/**
 * User: th3sly
 * Date: 1/15/12
 * Time: 9:39 PM
 */

public class StorageConverter {
    public static StorageBO convertToBO(Storage storage) {
        StorageBO storageBO = new StorageBO();
        storageBO.setAddress(storage.getAddress());
        storageBO.setName(storage.getAddress());
        if (storageBO.getKey() != null) {
            storageBO.setKey(KeyFactory.keyToString(storage.getKey()));
        }

        return storageBO;
    }

    public static Storage convertToDAOEntity(StorageBO storageBO) {
        Storage storage = new Storage();
        storage.setAddress(storageBO.getAddress());
        storage.setName(storageBO.getAddress());
        if (storageBO.getKey() != null) {
            storage.setKey(KeyFactory.stringToKey(storageBO.getKey()));
        }

        return storage;
    }
}
